#include <iostream>
#include <string>
#include <vector>
#include <sstream>

int main()
{
    std::ifstream in("data"); // 打开文件
    if(!in)
    {
        std::cerr << "Cann't open input file." << std::endl;
        return -1;
    }
    
    std::string line;
    std::vector<std::string> words;
    while(std::getline(in, line)) // 从文件中读取一行
    {
        words.push_back(line); // 添加到 vector 中
    }
    in.close(); // 输入完毕，关闭文件

    std::vector<std::string>::const_iterator it = words.begin(); // 迭代器
    while(it != words.end()) // 遍历 vector
    {
        std::istringstream line_str(*it);
        std::string word;
        while(line_str >> word) // 通过 istringstream从 vector 中读取数据
        {
            std::cout << word << " ";
        }
        std::cout << std::endl;
        ++it;
    }
    return 0;
}